const mongoose = require("mongoose");
const Schema = mongoose.Schema;

// Create Schema
const AddressSchema = new Schema(
  {
    user: {
      type: Schema.Types.ObjectId,
      ref: "User",
      required: true,
    },
    name: {
      type: String,
      required: true,
    },
    phone: {
      type: String,
      required: true,
    },
    region: {
      type: String,
      required: true,
    },
    detailedAddress: {
      type: String,
      required: true,
    },
    defaultAddress: {
      type: Boolean,
      default: false,
    },
    tag: {
      type: String,
    },
  },
  { versionKey: false }
);

module.exports = Address = mongoose.model("address", AddressSchema);
